
/**
 *	\file Definition of the nmn::output_message function.
 *	\author Sean Tromans
 */

#ifndef	NMN_OUTPUT_MESSAGE_HPP
#define	NMN_OUTPUT_MESSAGE_HPP

#ifndef	NMN_OUTPUT_MESSAGES_ON
#define	NMN_OUTPUT_MESSAGES_ON 1
#endif	//NMN_OUTPUT_MESSAGES_ON

#if NMN_OUTPUT_MESSAGES_ON

#include <needs_more_ninja/template/create_string.hpp>
#include <iostream>

#if		defined(WIN32)
#include <windows.h>
#else
#error Unrecognised platform
#endif

#define	NMN_DEFINE_OUTPUT_MESSAGE(z, n, _)																						\
	template < BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(n), class T) >															\
	inline void output_message( std::string const & format, BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_INC(n), T, const & p) )	\
	{																															\
		nmn::output_message( nmn::create_string( format, BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(n), p) ) );						\
	}

namespace nmn
{

	/**
	 *	Creates a string via nmn::create_string and outputs it to the console or debug window.
	 *	@param format The format the string should take.
	 *	@return The generated string.
	 *	\author Sean Tromans
	 */
	inline void output_message( std::string const & format )
	{
		std::cout << format << std::endl;

#if		defined(WIN32)
			OutputDebugStringA( format.c_str( ) );
			OutputDebugStringA( "\n" );
#else
#error Unrecognised platform
#endif
	}

	BOOST_PP_REPEAT( BOOST_PP_INC(NMN_CREATE_STRING_TOTAL_PARAMS), NMN_DEFINE_OUTPUT_MESSAGE, 0 );

};

#undef	NMN_DEFINE_OUTPUT_MESSAGE

#else

namespace nmn
{
	inline void	output_message(...)
	{
	}
};

#endif

#endif	//NMN_OUTPUT_MESSAGE_HPP
